// reading a text file
#include <iostream>
#include <fstream>
#include <string>
#include <sys/stat.h>

using namespace std;

int main () {
	string line;
	ifstream myfile ("test.jpg",ios::binary);
	ofstream outfile("testout.jpg");
	CFile aFile;
	aFile.Open("test.jpg", CFile::modeRead | CFile::typeBinary);
	
	if (myfile.is_open() && outfile.is_open()){
		myfile.seekg(0, ios::end);
       
		size_t len = myfile.tellg();
		cout << len << endl;
		char* fileBytes = new char[len];
		myfile.seekg(0, ios::beg);
		myfile.read(fileBytes, len);
		outfile << fileBytes << endl;
		myfile.close();
		outfile.close();
	}
	return 0;
}
